package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductUnusualFeedbackConfirmView;
import com.cloudsigns.factorymanager2.produce.model.IProductUnusualFeedbackConfirmModel;
import com.cloudsigns.factorymanager2.produce.model.ProductUnusualFeedbackConfirmModel;

public class ProductUnusualFeedbackConfirmPresenter {
    private IProductUnusualFeedbackConfirmView view;
    private IProductUnusualFeedbackConfirmModel model;
    private Handler handler = new Handler();

    public ProductUnusualFeedbackConfirmPresenter(IProductUnusualFeedbackConfirmView view) {
        this.view = view;
        this.model = new ProductUnusualFeedbackConfirmModel();
    }

    public void productUnusualFeedbackConfirm() {
        model.productUnusualFeedbackConfirm(view.getOrderId(), view.getProductId(), view.getType(), view.getWorkPartFeedbackId(), view.getWorkPartId(), view.getWorkPartOrderId(), view.getWorkPartScheduleItemRequestList(), new ProductUnusualFeedbackConfirmModel.OnProductUnusualFeedbackConfirmListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductUnusualFeedbackConfirmSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(String desc) {
                view.getProductUnusualFeedbackConfirmFailed(desc);
                view.hideLoading();
            }
        });
    }
}
